package lk.mrt.cse.wihidum.router.storage;

import org.apache.log4j.Logger;

import java.util.Map;
import java.util.HashMap;
import java.security.KeyStore;

/**
 * Created by IntelliJ IDEA.
 * User: Wihidum
 * Date: Jun 3, 2010
 * Time: 7:22:25 PM
 * To change this template use File | Settings | File Templates.
 */
public class ClientMap
{
    private static final Logger logger=Logger.getLogger(ClientMap.class);
    private static Map<String ,String> clientMap=new HashMap<String,String>();
    
    public static String saveClient(String id, String clientData)
    {
        clientMap.put(id, clientData);
        return "Client was registered successfully";
    }

    public static String getClientList()
    {
        String clientList = "";
        if(!clientMap.isEmpty())
        {
            int i = 0;
            for(Map.Entry<String, String> entry: clientMap.entrySet())
            {
                if(i==0)
                {
                    clientList = entry.getValue();
                    i = -1;
                }
                else
                    clientList = clientList.concat("@"+entry.getValue());
            }
        }
        return clientList;
    }

    public static String getClient(String id)
    {
        return clientMap.get(id);
    }
}
